package org.yang.snake.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *
 * @author shichenyang
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    /**
     * 返回编码
     */
    private int code;

    /**
     * 返回信息
     */
    private String msg;

    /**
     * 返回数据
     */
    private Object data;
    /**
     * 返回字符串
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long count;

    public static Result ok(String msg){
        return Result.builder().msg(msg).build();
    }
    public static Result ok(String msg,Object data){
        return Result.builder().msg(msg).data(data).build();
    }

    public static Result ok(String msg,Object list,Long count){
        return Result.builder().msg(msg).count(count).data(list).build();
    }

    public static Result err(String msg){
        return Result.builder().msg(msg).code(-1).build();
    }
}
